package DiErZhou.Secondweek;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Student {
    private String studentId;
    private String name;
    private int age;
    double score1, score2;
    private double totalScore, averageScore;

    public Student(String studentId, String name, int age, double score1, double score2) {
        this.studentId = studentId;
        this.name = name;
        this.age = age;
        this.score1 = score1;
        this.score2 = score2;
        this.totalScore = score1 + score2;
        this.averageScore = totalScore / 2;
    }
    public static void main(String[] args) {
        List<Student> students = new ArrayList<>();
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入学生学号：");
        String studentId = scanner.next();
        System.out.print("请输入学生姓名：");
        String name = scanner.next();
        System.out.print("请输入学生年龄：");
        int age = scanner.nextInt();
        System.out.print("请输入成绩1：");
        double score1 = scanner.nextDouble();
        System.out.print("请输入成绩2：");
        double score2 = scanner.nextDouble();
        Student student = new Student(studentId, name, age, score1, score2);
        students.add(student);
        System.out.print("请输入要查询的学生学号：");
        String queryId = scanner.next();
        for (Student s:students) {
            if (s.studentId.equals(queryId)) {
                System.out.println("学生姓名：" + s.name);
                System.out.println("学生年龄：" + s.age);
                System.out.println("成绩1：" + s.score1);
                System.out.println("成绩2：" + s.score2);
                System.out.println("总分：" + s.totalScore);
                System.out.println("平均分：" + s.averageScore);
            }
        }
    }
}
